clear
clc

n = 100;
x = linspace(0,6,n);
%边界线
s1 = 10-2.*x;
s2 = 6-3.*x;
s3 = (4-x)./2;

% trix = [0 1.6 4 5 0];%交点
% triy = [6 1.2 0 0 10];

trix = [2 4 5 2];%交点
triy = [1 0 0 6];

plot(x,s1,x,s2,x,s3);
hold on
fill(trix,triy,'cyan','FaceAlpha',0.3);
hold on
f = (2*trix(1)+triy(1)-2*x);
plot(x,f,'--');
hold on
plot([2 2],[0 10]);
legend('2x1+x2<=10','3x1+x2>=6','x1+2x2>=4','凸集','最优解','x=2');
xlim([0 5]);
ylim([0 10]);
% xlim([0 3]);
% ylim([0 3]);

disp(['max = ',num2str(2*trix(1)+1*triy(1))]);

%[x,y]=linprog(f,a,b,aeq,beq,zeros(3,1));